package com.nave.view;

import java.util.ArrayList;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import nave.model.GameObject;
import android.opengl.GLSurfaceView;

/*
 * THIS IS FOR OpenGL IMPLEMENTATION
 * WORK ON IT LATER!
 */
public class NaveRenderer implements GLSurfaceView.Renderer
{	
	/*
	 * Attributes
	 */
//	private static ArrayList<GameObject> objects; // TODO will probably use this
	
	/*
	 * Getters and Setters
	 */
	public void setObjects(ArrayList<GameObject> objects)
	{
//		this.objects = objects; // TODO
	}

	@Override
	public void onDrawFrame(GL10 gl)
	{
		// TODO Auto-generated method stub
		gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
	}

	@Override
	public void onSurfaceChanged(GL10 gl, int width, int height)
	{
		// TODO is it done?
		gl.glViewport(0, 0, width, height);

	    // make adjustments for screen ratio
	    float ratio = (float) width / height;
	    gl.glMatrixMode(GL10.GL_PROJECTION);        // set matrix to projection mode
	    gl.glLoadIdentity();                        // reset the matrix to its default state
	    gl.glFrustumf(-ratio, ratio, -1, 1, 3, 7);  // apply the projection matrix
	}

	@Override
	public void onSurfaceCreated(GL10 gl, EGLConfig config)
	{
		// TODO
		gl.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
	}
}
